<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>squareEquation: sqrEq.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">squareEquation
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Macros</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">sqrEq.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br/>
<code>#include &lt;math.h&gt;</code><br/>
<code>#include &lt;float.h&gt;</code><br/>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a0966b817b229d48e5ffc7feab19a0be6"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sqrEq_8c.html#a0966b817b229d48e5ffc7feab19a0be6">ASSERT</a>(cond)</td></tr>
<tr class="memdesc:a0966b817b229d48e5ffc7feab19a0be6"><td class="mdescLeft">&#160;</td><td class="mdescRight">DEBUG.  <a href="#a0966b817b229d48e5ffc7feab19a0be6">More...</a><br/></td></tr>
<tr class="separator:a0966b817b229d48e5ffc7feab19a0be6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a16f6a3671d5b0eceb9a80717e7fe61ab"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a16f6a3671d5b0eceb9a80717e7fe61ab"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sqrEq_8c.html#a16f6a3671d5b0eceb9a80717e7fe61ab">printErr</a>(str)&#160;&#160;&#160;printf(&quot;#ERROR: %s&quot;, str)</td></tr>
<tr class="memdesc:a16f6a3671d5b0eceb9a80717e7fe61ab"><td class="mdescLeft">&#160;</td><td class="mdescRight">prints an error massage <br/></td></tr>
<tr class="separator:a16f6a3671d5b0eceb9a80717e7fe61ab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1185cc91ef7daf1182d0902efbdffaae"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1185cc91ef7daf1182d0902efbdffaae"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sqrEq_8c.html#a1185cc91ef7daf1182d0902efbdffaae">printInvit</a>&#160;&#160;&#160;printf(&quot;&gt;&gt; &quot;)</td></tr>
<tr class="memdesc:a1185cc91ef7daf1182d0902efbdffaae"><td class="mdescLeft">&#160;</td><td class="mdescRight">prints an invitation for input <br/></td></tr>
<tr class="separator:a1185cc91ef7daf1182d0902efbdffaae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a298b948eb165f3290e0f5d409348662b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><b>signStr</b>(x)</td></tr>
<tr class="separator:a298b948eb165f3290e0f5d409348662b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ae02aea507f46dd0581eb6a1f1f2da52d"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sqrEq_8c.html#ae02aea507f46dd0581eb6a1f1f2da52d">MainReturn_t</a> { <a class="el" href="sqrEq_8c.html#ae02aea507f46dd0581eb6a1f1f2da52da3ac537b3b82f44af9d005a73d3c4920e">NoErr</a> = 0, 
<a class="el" href="sqrEq_8c.html#ae02aea507f46dd0581eb6a1f1f2da52da629456883b0673c3e8a7ff4cbd2c3527">UnknownErr</a> = 1, 
<a class="el" href="sqrEq_8c.html#ae02aea507f46dd0581eb6a1f1f2da52dab88d9ce4be35b9fcc7bac138b43380b7">InputErr</a> = 2
 }</td></tr>
<tr class="separator:ae02aea507f46dd0581eb6a1f1f2da52d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5b01d33fa7429b126fb983e362a32fe7"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7">SolveSquareReturn_t</a> { <br/>
&#160;&#160;<a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7ac68d3b603c25e8249b83604ee5c3521c">InfRoots</a> = -1, 
<a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7a58587f73761d33e01ac6765708c4b9c3">NoRoots</a> = 0, 
<a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7aa1ac608004f79e9d38254ca018bc108e">OneRoot</a> = 1, 
<a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7aa1733e118286438f67558a7231221b61">TwoRoots</a> = 2, 
<br/>
&#160;&#160;<a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7a4dfd42ec49d09d8c6555c218301cc30f">Error</a> = 13
<br/>
 }</td></tr>
<tr class="separator:a5b01d33fa7429b126fb983e362a32fe7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a906d996a8326ac4a5fb4a778ea44c5fa"><td class="memItemLeft" align="right" valign="top"><a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7">SolveSquareReturn_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sqrEq_8c.html#a906d996a8326ac4a5fb4a778ea44c5fa">solveSquare</a> (float a, float b, float c, float *x1, float *x2)</td></tr>
<tr class="separator:a906d996a8326ac4a5fb4a778ea44c5fa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a712b44ba9ce907670009c85df5f9c44f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="sqrEq_8c.html#a712b44ba9ce907670009c85df5f9c44f">printEquation</a> (float a, float b, float c)</td></tr>
<tr class="separator:a712b44ba9ce907670009c85df5f9c44f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>main</b> ()</td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><hr/>
<dl class="section date"><dt>Date</dt><dd>2013-10-27 15:08 </dd></dl>
<dl class="section author"><dt>Author</dt><dd>Daniil Vodopian <a href="#" onclick="location.href='mai'+'lto:'+'dgv'+'od'+'opy'+'an'+'@gm'+'ai'+'l.c'+'om'; return false;">dgvod<span style="display: none;">.nosp@m.</span>opya<span style="display: none;">.nosp@m.</span>n@gma<span style="display: none;">.nosp@m.</span>il.c<span style="display: none;">.nosp@m.</span>om</a> </dd></dl>
<dl class="section version"><dt>Version</dt><dd>1.03</dd></dl>
<p>Solving a square equation with minding all cases.</p>
<dl class="section user"><dt>Task:</dt><dd>input: 3 coefficients of a square equation ouput: number of its roots (-1 in infinity) and the roots themselves (if exist)</dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">0(NoErr)</td><td>no errors occurred </td></tr>
    <tr><td class="paramname">1(UnknownErr)</td><td>an unknown exception happened </td></tr>
    <tr><td class="paramname">2(InputErr)</td><td>incorrect input</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>The precision of output is the second digit after the decimal point</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>Do NOT kill the program! It will close by itself after an incorrect input. If you want to stop using the program, enter empty line when asked. </dd></dl>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a0966b817b229d48e5ffc7feab19a0be6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ASSERT</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cond)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line"><span class="keywordflow">if</span> (!(cond)) {                                  \</div>
<div class="line">    printf(<span class="stringliteral">&quot;ERROR: %s, file: %s, line: %d\n&quot;</span>,       \</div>
<div class="line">        #cond, __FILE__, __LINE__);                 \</div>
<div class="line">    abort();                                        \</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>DEBUG. </p>

</div>
</div>
<a class="anchor" id="a298b948eb165f3290e0f5d409348662b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define signStr</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">x)</td><td></td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">(   \</div>
<div class="line">    (x == 0) ? <span class="stringliteral">&quot; &quot;</span>  :   \</div>
<div class="line">    (x &lt; 0)  ? <span class="stringliteral">&quot;- &quot;</span> :   \</div>
<div class="line">    (x &gt; 0)  ? <span class="stringliteral">&quot;+ &quot;</span> : <span class="stringliteral">&quot;&quot;</span>)</div>
</div><!-- fragment -->
</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a class="anchor" id="ae02aea507f46dd0581eb6a1f1f2da52d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="sqrEq_8c.html#ae02aea507f46dd0581eb6a1f1f2da52d">MainReturn_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="ae02aea507f46dd0581eb6a1f1f2da52da3ac537b3b82f44af9d005a73d3c4920e"></a>NoErr</em>&nbsp;</td><td class="fielddoc">
<p>No errors occurred. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ae02aea507f46dd0581eb6a1f1f2da52da629456883b0673c3e8a7ff4cbd2c3527"></a>UnknownErr</em>&nbsp;</td><td class="fielddoc">
<p>An unknown exception happened. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ae02aea507f46dd0581eb6a1f1f2da52dab88d9ce4be35b9fcc7bac138b43380b7"></a>InputErr</em>&nbsp;</td><td class="fielddoc">
<p>Incorrect input. </p>
</td></tr>
</table>

</div>
</div>
<a class="anchor" id="a5b01d33fa7429b126fb983e362a32fe7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7">SolveSquareReturn_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="a5b01d33fa7429b126fb983e362a32fe7ac68d3b603c25e8249b83604ee5c3521c"></a>InfRoots</em>&nbsp;</td><td class="fielddoc">
<p>Infinitive number of roots. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="a5b01d33fa7429b126fb983e362a32fe7a58587f73761d33e01ac6765708c4b9c3"></a>NoRoots</em>&nbsp;</td><td class="fielddoc">
<p>No roots exist. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="a5b01d33fa7429b126fb983e362a32fe7aa1ac608004f79e9d38254ca018bc108e"></a>OneRoot</em>&nbsp;</td><td class="fielddoc">
<p>One root. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="a5b01d33fa7429b126fb983e362a32fe7aa1733e118286438f67558a7231221b61"></a>TwoRoots</em>&nbsp;</td><td class="fielddoc">
<p>Two roots. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="a5b01d33fa7429b126fb983e362a32fe7a4dfd42ec49d09d8c6555c218301cc30f"></a>Error</em>&nbsp;</td><td class="fielddoc">
<p>Any error. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a712b44ba9ce907670009c85df5f9c44f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void printEquation </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>b</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>c</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<hr/>
<p> printEquation - print a square equation specified by its coefficients in the form a*(x^2) + b*x + c = 0</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>Equation a-coefficient </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">b</td><td>Equation b-coefficient </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">c</td><td>Equation c-coefficient</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>it prints the only line without '\n' symbols </dd></dl>

</div>
</div>
<a class="anchor" id="a906d996a8326ac4a5fb4a778ea44c5fa"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="sqrEq_8c.html#a5b01d33fa7429b126fb983e362a32fe7">SolveSquareReturn_t</a> solveSquare </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>b</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>c</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float *&#160;</td>
          <td class="paramname"><em>x1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float *&#160;</td>
          <td class="paramname"><em>x2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<hr/>
<p> solveSquare - solve a square equation specified by its coefficients in the form a*(x^2) + b*x + c = 0</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>Equation a-coefficient </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">b</td><td>Equation b-coefficient </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">c</td><td>Equation c-coefficient </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">x1</td><td>1st root of equation, if exist (if not, value will be unchanged) </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">x2</td><td>2nd root of equation, if exist (if not, value will be unchanged)</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of roots or zero if none, -1 if infinite number of roots</dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">-1(InfRoots)</td><td>Infinitive number of roots </td></tr>
    <tr><td class="paramname">0(NoRoots)</td><td>No roots exist </td></tr>
    <tr><td class="paramname">1(OneRoot)</td><td>One root </td></tr>
    <tr><td class="paramname">2(TwoRoots)</td><td>Two roots </td></tr>
    <tr><td class="paramname">13(Error)</td><td>Any error</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Calculation precision is considered to be FLT_EPSILON. </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Oct 28 2013 12:07:21 for squareEquation by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.4
</small></address>
</body>
</html>
